package com.helloae.chap07;

import java.io.IOException;
import java.net.UnknownHostException;

import com.esri.arcgis.carto.Map;
import com.esri.arcgis.geometry.GeographicCoordinateSystem;
import com.esri.arcgis.geometry.IGridTransformation;
import com.esri.arcgis.geometry.ITransformation;
import com.esri.arcgis.geometry.SpatialReferenceEnvironment;
import com.esri.arcgis.geometry.esriSRGeoTransformation2Type;
import com.esri.arcgis.system.AoInitialize;
import com.esri.arcgis.system.EngineInitializer;
import com.esri.arcgis.system.esriLicenseProductCode;

/**
 * 使用SpatialReferenceEnvironment.createGeoTransformation创建ISpatialReference并赋给IMap<br>
 * 示例章节：7.5.1
 * @author light
 *
 */
public class NAD27to83_Map {

	public static void main(String[] args) throws UnknownHostException, IOException {
		// 初始化AE许可
		EngineInitializer.initializeEngine();
		AoInitialize ao = new AoInitialize();
		ao.initialize(esriLicenseProductCode.esriLicenseProductCodeEngine);

		SpatialReferenceEnvironment pSpatRefFact = new SpatialReferenceEnvironment();
		ITransformation pTemp = pSpatRefFact.createGeoTransformation(esriSRGeoTransformation2Type.esriSRGeoTransformation_NAD_1927_TO_NAD_1983_NADCON);
		IGridTransformation pGeotransNAD27toNAD83 = (IGridTransformation)pTemp;
		
		GeographicCoordinateSystem[] pFromGCS = new GeographicCoordinateSystem[1];
		GeographicCoordinateSystem[] pToGCS = new GeographicCoordinateSystem[1];
		
		pGeotransNAD27toNAD83.getSpatialReferences(pFromGCS, pToGCS);
		
		Map pMap = new Map();
		pMap.setSpatialReferenceByRef(pToGCS[0]);
		
		ao.shutdown();
		System.out.println("Congratulations!");
	}

}
